import Vue from 'vue'
import VueRouter from 'vue-router'


// import UserInfo from '@/views/Menus/User/UserInfo.vue'


// @ 代表src

Vue.use(VueRouter)

const routes = [
  // {
  //   path:'/',
  //   redirect:'/login'
  // },
  {
    path: '/',
    name: 'Main',
    component: () => import("@/views/Main/Main.vue"),
    redirect: '/home',
    children: [
      {
        name: 'Home',
        path: 'home',
        component:  () => import('@/views/Menus/Home/Home.vue'),
      },
      { 
        path: 'user-info',
        component:  () => import('@/views/Menus/User/UserInfo.vue') 
      },
      {
        path: 'user-avatar',
        component:  () => import('@/views/Menus/User/UserAvatar.vue') 
      },
      {
        path: 'user-pwd',
        component:  () => import('@/views/Menus/User/UserPwd.vue') 
      },
      { 
        path: 'art-cate',
        component:  () => import('@/views/Menus/Article/ArtCate.vue') 
      },
      { 
        path: 'art-list',
        component:  () => import('@/views/Menus/Article/ArtList.vue') 
      },
    ]
  },
  {
    name: 'login',
    path: '/login',
    component:  () => import('../views/Login/Login.vue'),
  },
  {
    name: 'reg',
    path: '/Reg',
    component:  () => import("@/views/Reg/Reg.vue"),
  },
]

const router = new VueRouter({
  routes
})
//路由重复跳转,捕获
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router
